<template>
  <!-- 全局配置 -->
  <el-config-provider :locale="zhCn">
    <div class="app">
      <router-view />
      <el-button type="primary" @click="loadData">登录</el-button>

      <el-pagination :page-sizes="[100, 200, 300, 400]" layout="total, sizes, prev, pager, next, jumper" :total="400" />

      <el-date-picker
        type="date"
        placeholder="Pick a day"
      />
    </div>
  </el-config-provider>
</template>

<script setup lang="ts">
// element-plus 中的简体中文语言包
import zhCn from 'element-plus/es/locale/lang/zh-cn'

// 引入封装后的 axios 实例
import request from '@/utils/request'

const loadData = async () => {
  // 发送网络请求，调用泛型函数时，第二个类型指的就是后端响应返回的正确业务数据类型
  const result = await request<any, ILoginSuccess>({
    url: '/api/v1/admin/sessions',
    method: 'POST',
    data: {
      username: 'admin11',
      password: 'admin',
    },
  })

  if (result.status === 200) {
    console.log('登录成功:', result.token)
  } else {
    console.log(result.message)
  }

  // console.log('登录结果:', result)
}
</script>

<style>
:root:root {
  --el-color-primary: red;
}
</style>

<style lang="less" scoped></style>
